package com.clay.appointment.controller;

import com.clay.appointment.common.response.Result;
import com.clay.appointment.entity.hospital.Schedule;
import com.clay.appointment.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author : clay
 * @Description:
 * @Date: Create in 15:51 2021/8/19
 * @Modified By:
 */
@Api(tags = "科室时间安排")
@RestController
@RequestMapping("/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation(value = "根据医院编号和科室编号，查询排班规则信息")
    @GetMapping(value = "getScheduleRule/{page}/{limit}/{hospitalCode}/{departmentCode}")
    public Result getScheduleRule(
            @ApiParam("页码") @PathVariable("page") Integer page,
            @ApiParam("每页记录数") @PathVariable("limit") Integer limit,
            @ApiParam("医院编号") @PathVariable("hospitalCode") String hospitalCode,
            @ApiParam("科室编号") @PathVariable("departmentCode") String departmentCode) {
        Map<String, Object> ScheduleRule = scheduleService.getScheduleRule(page, limit, hospitalCode, departmentCode);
        return Result.success(ScheduleRule);
    }

    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hospitalCode}/{departmentCode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hospitalCode,
                                    @PathVariable String departmentCode,
                                    @PathVariable String workDate) {
        List<Schedule> list = scheduleService.getDetailSchedule(hospitalCode, departmentCode, workDate);
        return Result.success(list);
    }
}
